const data = {
  nodes: [{
    id: 'node1',
    shape: 'customNode',
    style: {
        fill: 'red',
        stroke: 'blue'
    },
    label: {
        text: '测试\n测试测试测试测试',
        fill: '#fff'
    },
    x: 50,
    y: 250
  },{
    id: 'node2',
    shape: 'customNode',
    x: 450,
    y: 250
  }],
  edges: [{
    id: 'edge1',
    target: 'node2',
    source: 'node1'
  }]
};
G6.registerNode('customNode', {
  draw(item){
    const group = item.getGraphicGroup();
    const html = G6.Util.createDOM('<div class="node">HTML 节点</div>');
    return group.addShape('dom', {
      attrs: {
        x: 0,
        y: 0,
        width: 100,
        height: 24,
        html
      }
    });
  }
});
const graph = new G6.Graph({
  renderer: 'svg',
  container: 'mountNode',
  width: 500,
  height: 500
});
graph.read(data);

graph.on('node:click', ev=>{
  const { domEvent, item } = ev;
  const { target } = domEvent;
  if(target && target.dataset.text){
     alert('捕获了一只'+target.dataset.text);
  }
});